package com.baiku.sanhos.controller;

import com.baiku.sanhos.mapper.RecipeMapper;
import com.baiku.sanhos.pojo.vo.UserInventoryVO;
import com.baiku.sanhos.response.ResultVO;
import com.baiku.sanhos.utils.model.SanhosDataModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @author ruoLi
 */
@Api(tags = "打印")
@RestController
@RequestMapping("/pa/print")
public class PrintController {
    @Autowired
    RecipeMapper recipe;
    @Autowired
    SanhosDataModel sanhosDataModel;

    /**
     * 根据recordId 编号开始打印项目清单
     * @param recordId 就诊id
     * @return ResultVO
     *
     * 加医生权限
     */
    @ApiOperation("打印项目清单")
    @GetMapping("/printInventory/{recordId}")
    @PreAuthorize("hasAuthority('DDD') or hasAuthority('AAA')")
    public ResultVO printInventory(@PathVariable Integer recordId){
        UserInventoryVO inventory = recipe.userInventory(recordId);
        return  sanhosDataModel.printInventory(inventory);
    }
}
